package ua.pp.pycb6a.seposition.helper;

import static ua.pp.pycb6a.seposition.helper.WriterHelper.getWriter;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;

public final class PropertyHelper {

    private static Properties properties;

    private PropertyHelper() {

    }

    public static Properties getProperties() {

        properties = new Properties();

        try {
            properties.load(new FileInputStream("config.properties"));
        } catch (IOException e) {
            getWriter().println("PROPERTIES FILE NOT FOUND");
        }
        return properties;
    }

    public static String getWebAddress() {

        return getProperties().getProperty("webaddress");
    }

    public static List<String> getKeywords() {

        List<String> keywords = new ArrayList<String>();
        for (String key : getProperties().keySet().toArray(
                new String[getProperties().size()])) {

            if (key.startsWith("keywords.")) {
                keywords.add(getProperties().getProperty(key));
            }
        }
        Collections.reverse(keywords);
        return keywords;
    }
}
